#pragma once
#include "UIAnimation.h"

namespace DirectUI
{
	class CUIVisualState 
		: public CUINoAggregateObjectImplHelper<IUIVisualState, CUIVisualState, IUIVisualState>
		// IUIVisualState
	{
		DECLARE_CLASS(CUIVisualState, VisualState)
	public:
		CUIVisualState();
		~CUIVisualState();

		virtual	LPCTSTR GetName() { return m_szName; }
		virtual	void SetName(LPCTSTR lpszName) { m_szName = lpszName; }
		virtual DirectUI::UIAnimation::IUIStoryboard* GetStoryboard();
		virtual void SetStoryboard( DirectUI::UIAnimation::IUIStoryboard* lpStoryboard );

		virtual HRESULT QueryInterface( const GUID& guid, void** lppObject );
	private:
		CUIObjectPtr<UIAnimation::IUIStoryboard>	m_spStoryboard;
		CString										m_szName;
	};

	class CUIVisualStateGroup
		: public CUINoAggregateObjectImplHelper<IUIVisualStateGroup, CUIVisualStateGroup, IUIVisualStateGroup>
		// IUIVisualStateGroup
	{
		DECLARE_CLASS(CUIVisualStateGroup, VisualStateGroup)
	public:
		CUIVisualStateGroup();
		~CUIVisualStateGroup();

		virtual	LPCTSTR				GetName() { return m_szName; }
		virtual	void				SetName(LPCTSTR lpszName) { m_szName = lpszName; }
		virtual IUIVisualState*		GetCurrentState() { return m_spCurrentState; }
		virtual	void				AddVisualState(IUIVisualState* lpVisualState);
		virtual HRESULT				QueryInterface( const GUID& guid, void** lppObject );

		virtual void				GotoState(IUIElement* lpStateOwner, LPCTSTR lpszState);

	private:
		std::map<CString, CUIObjectPtr<IUIVisualState>>		m_mapVisualStates;
		CUIObjectPtr<IUIVisualState>						m_spCurrentState;
		CString												m_szName;
	};

	class CUIVisualStateManager : public IUIVisualStateManager
	{
	public:
		CUIVisualStateManager(void);
		virtual ~CUIVisualStateManager(void);

		virtual void				GoToState(IUIElement* lpElement, LPCTSTR lpszState);
		virtual void				GoToElementState(IUIElement* lpElement, LPCTSTR lpszState);
	};
}
